#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "user.h"
#include "room.h"
#include "bill.h"
#include "customer.h"

int receptMenu()
{
	int c;
	showTime(1);
	printf("\t\t\t         旅店管理系统\n");
	printf("\t\t\t=============================\n");
	printf("\t\t\t       前台服务 管理系统\n");
	printf("\t\t\t   * 1 查询房间\n");
	printf("\t\t\t   * 2 退房\n");
	printf("\t\t\t   * 3 换房\n");
	printf("\t\t\t   * 4 续住\n");
	printf("\t\t\t   * 5 查看客人信息\n");
	printf("\t\t\t   * 6 修改个人信息\n");
	printf("\t\t\t   * 0 注销\n");
	printf("\t\t\t=============================\n");
	printf("\t\t\t请选择:");
	scanf("%d",&c);
	getchar();
	while(c < 0||c > 6)
	{
		printf("请重新输入:");
		scanf("%d",&c);
		getchar();
	}
	return c ;


}


void receptSystem(User *r)
{
	int c,c1,c5,loop = 1;
	int a;
	while(loop)
	{
		system("clear");
		//printf("\n%s",r->name);
		//showTime(1);
		c = receptMenu();
		switch(c)
		{
			case 1:
				printf(RED);
				printf("find foom\n");
				printf(NONE);
				recept_find_room();	
				printf("请选择:\n");
				printf("1.入住 2.预约 3.退出\n");
				scanf("%d",&c1);
				getchar();
				switch(c1)
					{
						case 1:		
							a = check_in();
							if(!a)
							{
								printf(YELLOW);
								printf("入住结账\n");
								printf(NONE);
								check_out_rz();
								printf(YELLOW);
								printf("入住登记\n");
								printf(NONE);
								register_rz();
							}
							printf("输入任意指令以继续:\n");
							getchar();
							break;
						case 2:		
							a = order_in();
							if(!a)
							{
								printf(YELLOW);
								printf("预约结账\n");
								printf(NONE);
								check_out_yy();
								printf(YELLOW);
								printf("预约登记\n");
								printf(NONE);
								register_yy();
							}
							printf("输入任意指令以继续:\n");
							getchar();
							break;	
						case 3:
						default:
							break;
					}	
				break;
			case 2:
				printf(RED);
				printf("free room\n");
				printf(NONE);
				a = free_room();
				if(!a)
				{
					printf(YELLOW);
					printf("退房\n");
					printf(NONE);
					free_customer();
				}
				printf("输入任意指令以继续:\n");
				getchar();
				break;
			case 3:
				printf(RED);
				printf("exchange room\n");
				printf(NONE);
				a = exchange_room();
				if(!a)
				{
					printf(YELLOW);
					printf("换房\n");
					printf(NONE);
					check_out_hf();
					printf(YELLOW);
					printf("换房\n");
					printf(NONE);
					exchange_room_customer();
				}
				printf("输入任意指令以继续:\n");
				getchar();
				break;
			case 4:
				printf(RED);
				printf("keep room\n");
				printf(NONE);
				a = keep_room();
				if(!a)
				{
					printf(YELLOW);
					printf("续住\n");
					printf(NONE);
					keep_room_customer();
					printf(YELLOW);
					printf("续住\n");
					printf(NONE);
					keep_room_bill();
				}
				printf("输入任意指令以继续:\n");
				getchar();
				break;
			case 5:
				printf(RED);
				printf("show customer information\n");
				printf("查看客人信息\n");
				printf(NONE);
				printf("请选择:\n");
				printf("1.按房间号查询 2.按姓名查询 3.查看全部 0.退出\n");
				scanf("%d",&c5);
				getchar();
				switch(c5)
				{
					case 1 :
						find_customer_roomId();
						break;
					case 2 :
						find_customer_name();
						break;
					case 3 :
						find_customer_all();
						break;
					case 4 :
						break;
					case 5 :
					default:
						break;
				}
				printf("输入任意指令以继续:\n");
				getchar();
				break;
			case 6:
				printf(RED);
				printf("change my information\n");
				printf(NONE);
				change_my_userinf(r);
				break;
			case 0:
			default:
				loop = 0;
				break;
		}//switch(c)
	}
}

